#pragma once
#ifndef _FILE_UTILS_H_
#define _FILE_UTILS_H_
#ifdef WIN32
#pragma execution_character_set("utf-8")
#endif // WIN32


#include <QObject>
#include <QFile>
#include <QTextstream>
#include <QFileDialog>
#include <QDir>
#include <QUrl>
#include <QDebug>
#include <QDesktopServices>
#include <QStandardpaths>
#include <QtWidgets/QTableWidget>
#include "MyError.h"

/// <summary>
/// 文件处理工具
/// </summary>
namespace FileUtils {

	/// <summary>
	/// 获取保存路径
	/// </summary>
	/// <returns></returns>
	QString getSavePath(QString filter = ".xlsx", QWidget* parent = nullptr);


	/// <summary>
	/// 创建文件夹
	/// </summary>
	/// <param name="dirName"></param>
	void createDir(const QString& dirName);

	/// <summary>
	/// 递归删除文件夹以及文件夹中的文件
	/// </summary>
	/// <param name="path">文件路径</param>
	void deleteFile(const QString& path);

	/// <summary>
	/// 删除指定文件名下所有的文件
	/// </summary>
	/// <param name="baseDir"></param>
	/// <param name="keepCount"></param>
	void deleteFiles(const QString& baseDir);

	/// <summary>
	/// 删除过期的文件
	/// </summary>
	/// <param name="imgSavePath">图片保存路径</param>
	/// <param name="beforeTime">过期时间，删除beforeTime之前创建的文件</param>
	void deleteExpiresFiles(const QString& imgSavePath, const QDateTime& beforeTime);

	/// <summary>
	/// 获取桌面路径
	/// </summary>
	/// <returns></returns>
	QString getDesktopPath();

};

#endif


